<html>
<head><meta charset="utf-8"><title>wg-rls-2.0/macro-by-example · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/wg-rls-2.2E0.2Fmacro-by-example.html">wg-rls-2.0/macro-by-example</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="160950666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/wg-rls-2.0/macro-by-example/near/160950666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/wg-rls-2.2E0.2Fmacro-by-example.html#160950666">(Mar 16 2019 at 12:56)</a>:</h4>
<p>One piece of infrastructure we need to unlock macro-expansion/name resolution experimentation is handling of macro by example. Specifically:</p>
<ul>
<li>compiling a token tree into a macro (handling macro_rules itself)</li>
<li>matching a token stream against the set of patterns (first phase of mbe expansion)</li>
<li>producig a resulting token stream from the rules template and matched fragments (second phase of mbe expansion)</li>
</ul>
<p>There's a super prototype implementation in rust-analyzer already, and I wonder how we should expand  it further. For example, I can imagine we can fully libariify this, and share code with rustc (so, macro-by-example working subgroup can be formed). Or we can  write something useful for proc-macro authors (perhaps sharing code with nrc's proc-macro-rules). Or we can decide that full support of mbe is out of scope, and just make a minimal impl that allows experimentation with hygiene and incremental name resolution.</p>
<p>I don't really have any opinion here :) Perhaps someone from <span class="user-group-mention" data-user-group-id="1060">@WG-rls2.0</span> has more experience in this area?</p>



<a name="160950678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/wg-rls-2.0/macro-by-example/near/160950678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/wg-rls-2.2E0.2Fmacro-by-example.html#160950678">(Mar 16 2019 at 12:57)</a>:</h4>
<p>This commit sums up the current state of mbe in rust-analyzer pretty well <a href="https://github.com/rust-analyzer/rust-analyzer/pull/968/commits/fb6576b6b7f500c37123fd10b1c8f90d6d90219a" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/pull/968/commits/fb6576b6b7f500c37123fd10b1c8f90d6d90219a">https://github.com/rust-analyzer/rust-analyzer/pull/968/commits/fb6576b6b7f500c37123fd10b1c8f90d6d90219a</a> :)</p>



<a name="160955814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/wg-rls-2.0/macro-by-example/near/160955814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/wg-rls-2.2E0.2Fmacro-by-example.html#160955814">(Mar 16 2019 at 15:32)</a>:</h4>
<blockquote>
<p>We went looking everywhere, but couldn’t find those commits.</p>
</blockquote>
<p>I hope that's not the actual state of mbe in rust-analyzer ;)</p>



<a name="160955953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/wg-rls-2.0/macro-by-example/near/160955953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/wg-rls-2.2E0.2Fmacro-by-example.html#160955953">(Mar 16 2019 at 15:37)</a>:</h4>
<p>Usually indicates that the branch was force-pushed and indeed that specific commit hash is gone.</p>



<a name="160955996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/wg-rls-2.0/macro-by-example/near/160955996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/wg-rls-2.2E0.2Fmacro-by-example.html#160955996">(Mar 16 2019 at 15:38)</a>:</h4>
<p>Editing the URL to remove the SHA and go back to the PR proper is usually a good step</p>



<a name="160956260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/wg-rls-2.0/macro-by-example/near/160956260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/wg-rls-2.2E0.2Fmacro-by-example.html#160956260">(Mar 16 2019 at 15:46)</a>:</h4>
<p>Yeah, the situation is a tiny bit better: <a href="https://github.com/rust-analyzer/rust-analyzer/pull/968/commits/1bcc01822dbfc4f917105b5e22032ad8a728b33b" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/pull/968/commits/1bcc01822dbfc4f917105b5e22032ad8a728b33b">https://github.com/rust-analyzer/rust-analyzer/pull/968/commits/1bcc01822dbfc4f917105b5e22032ad8a728b33b</a> :D (link to commit, b/c PR is <em>huge</em>)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>